module.exports = {
     formatDate:(date)=> {
        const year = String(date.getFullYear());
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        return year + '-' + month + '-' + day;
      },
      // 月初
      startMonth:(date)=> {
        const year = String(date.getFullYear());
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        
        
            let newYear = year
            let newMonth = month
            let newDay = '01'
            return newYear + '-' + newMonth + '-' + newDay
        
      },
    //   月末
      endMonth:(date)=> {
        const year = String(date.getFullYear());
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        
        if(month*1 >= 12){
            let newYear = year*1+1
            let newMonth = '01'
            let newDay = '01'
            // console.log(newYear + '-' + newMonth + '-' + newDay);
            return newYear + '-' + newMonth + '-' + newDay
        }else{
            let newYear = year
            let newMonth = month * 1 +1
            let newDay = '01'
            // console.log(newYear + '-' + newMonth + '-' + newDay);
            return newYear + '-' + newMonth + '-' + newDay
        }
      },
    //   下一个月末
      nextEndMonth:(date)=> {
        const year = String(date.getFullYear());
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        
        if(month*1 >= 12){
            let newYear = year*1+1
            let newMonth = '02'
            let newDay = '01'
            // console.log(newYear + '-' + newMonth + '-' + newDay);
            return newYear + '-' + newMonth + '-' + newDay
        }else{
            let newYear = year
            let newMonth = month * 1 +2
            let newDay = '01'
            // console.log(newYear + '-' + newMonth + '-' + newDay);
            return newYear + '-' + newMonth + '-' + newDay
        }
      },
      
}
